package demo.MethodStaticReference;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class Test3 {
    public static void main( String[] args ) {
        // 理解构造器引用
        // 接口不能有对象，创建接口的匿名内部类对象。
//        TeacherInter t = new TeacherInter(){
//            @Override
//            public Teacher getTeacher( String name ) {
//                return new Teacher( name );
//            }
//        };

//        TeacherInter t =  name -> new Teacher( name );

        //构造器引用          类名::bew
        TeacherInter t = Teacher::new;

        Teacher teacher = t.getTeacher("张三");
        System.out.println(teacher);
    }
}

@FunctionalInterface
interface TeacherInter {
    Teacher getTeacher( String name );
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class Teacher {
    private String name;
}

